package com.balabala.gym_consume.controller.app;


import com.balabala.gym_consume.pojo.dto.OrderConfirmDTO;
import com.balabala.gym_consume.pojo.dto.OrderPageDTO;
import com.balabala.gym_consume.pojo.dto.OrderSubmitDTO;
import com.balabala.gym_consume.pojo.vo.OrderConfirmVO;
import com.balabala.gym_consume.pojo.vo.OrderSubmitVO;
import com.balabala.gym_consume.service.OrderService;
import com.balabala.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 何涛
 * @Date: 2023/05/08/ 10:33
 * @description 订单前台接口
 */
@RestController
@RequestMapping("/app/order")
@Slf4j
@Api(tags = "订单前台相关接口")
@CrossOrigin
public class OrderAppController {
    @Autowired
    OrderService orderService;



    @ApiOperation("订单列表")
    @GetMapping("/list")
    public Result list()
    {
        return Result.ok();
    }

    @ApiOperation("订单确认")
    @PostMapping("/confirm")
    public Result<OrderConfirmVO> confirm(@RequestBody OrderConfirmDTO orderConfirmDTO)
    {
        log.info("《==================================订单确认============================================》");

        return Result.ok(orderService.confirm(orderConfirmDTO));
    }

    @ApiOperation("订单提交")
    @PostMapping("/submit")
    public Result<OrderSubmitVO> submit(@RequestBody OrderSubmitDTO orderSubmitDTO){
        OrderSubmitVO orderSubmitVO=orderService.submit(orderSubmitDTO);
        return Result.ok(orderSubmitVO);
    }

    @ApiOperation("订单删除")
    @DeleteMapping("{orderId}")
    public Result deleteOrder(@PathVariable Long orderId)
    {
        log.info("《==================================订单删除============================================》");
        return Result.judge(orderService.deleteOrderByOrderId(orderId));
    }
    @ApiOperation("订单取消")
    @PutMapping("/cancel")
    public Result cancel(@RequestParam Long id)
    {
        log.info("《==================================订单取消============================================》");
        return Result.judge(orderService.cancelOrderById(id));
    }

    @ApiOperation("订单列表")
    @PostMapping("/list")
    public Result orderList(@RequestBody OrderPageDTO orderPageDTO)
    {
        return Result.ok(orderService.orderList(orderPageDTO));
    }



}
